package com.zbkj.service.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.zbkj.common.model.AiBackground;
import com.zbkj.common.request.AiBackgroundSearchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.service.dao.AiBackgroundDao;
import com.zbkj.service.service.AiBackgroundService;
import com.zbkj.service.service.SystemAttachmentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author keNan
 * @description AiBackgroundServiceImpl 接口实现
 * @date 2025-05-21
 */
@Service
public class AiBackgroundServiceImpl extends ServiceImpl<AiBackgroundDao, AiBackground> implements AiBackgroundService {

    @Autowired
    private AiBackgroundDao dao;
    @Autowired
    private SystemAttachmentService systemAttachmentService;


    /**
     * 列表
     *
     * @param request          请求参数
     * @param pageParamRequest 分页类参数
     * @return List<AiBackground>
     * @author keNan
     * @since 2025-05-21
     */
    @Override
    public List<AiBackground> getList(AiBackgroundSearchRequest request, PageParamRequest pageParamRequest) {
        PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());

        //带 AiBackground 类的多条件查询
        LambdaQueryWrapper<AiBackground> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        AiBackground model = new AiBackground();
        BeanUtils.copyProperties(request, model);
        model.setAiBackgroundName(null);
        lambdaQueryWrapper.setEntity(model);
        if (StrUtil.isNotBlank(request.getAiBackgroundName())) {
            lambdaQueryWrapper.like(AiBackground::getAiBackgroundName, request.getAiBackgroundName());
        }
        List<AiBackground> aiBackgroundList = dao.selectList(lambdaQueryWrapper);
        return aiBackgroundList;
    }


    /**
     * 查询ai试衣背景图列表
     *
     * @param pageParamRequest
     * @return
     */
    @Override
    public List<AiBackground> getFrontList(PageParamRequest pageParamRequest) {
        PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
        List<AiBackground> aiBackgroundList = dao.selectList(null);
        return aiBackgroundList;
    }


}

